<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
        class GoHome{
            constructor(){}
            init(){
                console.log("go home")
            }
        }
        // const g1 = new GoHome()
        // g1.init()

        class OpenComputer{
            constructor(){}
            init(){
                console.log("OpenComputer")
            }
        }
        // const o1 = new OpenComputer()
        // o1.init()

        class PlayGames{
            constructor(){}
            init(){
                console.log("PlayGames")
            }
        }
        // const p1 = new PlayGames()
        // p1.init()



        class Compose{
            constructor(){
                this.event = []
            }
            add(obj){
                this.event.push(obj)
            }
            init(){
                for(let i = 0 ; i < this.event.length ; i++){
                    this.event[i].init()
                }
            }
        }
        const c1 = new Compose()
        c1.add(new GoHome())
        c1.add(new OpenComputer())
        c1.add(new PlayGames())
        // console.log(c1)
        c1.init()
    </script>
</body>
</html>